import unittest
from HolidayTest import HolidayTest

import datetime
from Entities.Calendars.MoveableHoliday import MoveableHoliday

known_easters = \
    [
    '1990-04-15',
    '1991-03-31',
    '1992-04-19',
    '1993-04-11',
    '1994-04-03',
    '1995-04-16',
    '1996-04-07',
    '1997-03-30',
    '1998-04-12',
    '1999-04-04',
    '2000-04-23',
    '2001-04-15',
    '2002-03-31',
    '2003-04-20',
    '2004-04-11',
    '2005-03-27',
    '2006-04-16',
    '2007-04-08',
    '2008-03-23',
    '2009-04-12',
    '2010-04-04',
    '2011-04-24',
    '2012-04-08',
    '2013-03-31',
    '2014-04-20',
    '2015-04-05',
    '2016-03-27',
    '2017-04-16',
    '2018-04-01',
    '2019-04-21',
    '2020-04-12',
    '2021-04-04',
    '2022-04-17',
    '2023-04-09',
    '2024-03-31',
    '2025-04-20',
    '2026-04-05',
    '2027-03-28',
    '2028-04-16',
    '2029-04-01',
    '2030-04-21',
    '2031-04-13',
    '2032-03-28',
    '2033-04-17',
    '2034-04-09',
    '2035-03-25',
    '2036-04-13',
    '2037-04-05',
    '2038-04-25',
    '2039-04-10',
    '2040-04-01',
    '2041-04-21',
    '2042-04-06',
    '2043-03-29',
    '2044-04-17',
    '2045-04-09',
    '2046-03-25',
    '2047-04-14',
    '2048-04-05',
    '2049-04-18'
    ]
    
class MoveableHolidayTest (HolidayTest):
    
    def setUp (self):
        self.rd  = MoveableHoliday ("Test", 0)
        self.d1 = datetime.date (2011,04,24)
        self.d2 = datetime.date (2011,04,25)

    def testEaster (self):
        for datestr in known_easters:
            d = datetime.datetime.strptime (datestr, "%Y-%m-%d").date()
            self.assertEquals (d, MoveableHoliday.easter(d.year))
            
    def testHoliday(self):
        self.assertTrue  (self.rd.isholiday (self.d1))
        self.assertFalse (self.rd.isholiday (self.d2))

def Suite ():
    return unittest.TestLoader().loadTestsFromTestCase(MoveableHolidayTest)
        
if __name__ == '__main__':
    unittest.TextTestRunner().run(Suite())
    